//
//  ZYXInWenViewController.m
//  XiangMuYiBai
//
//  Created by mac on 15-4-19.
//  Copyright (c) 2015年 zhiyou. All rights reserved.
//

#import "ZYXInWenViewController.h"
#import "Header.h"
@interface ZYXInWenViewController ()

@end

@implementation ZYXInWenViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    //ZYAppDelegate *app=[UIApplication sharedApplication].delegate;
    UIImageView *beiJing=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    beiJing.image=[UIImage imageNamed:@"n_background@2x.png"];
    [self.view addSubview:beiJing];
//    XinWenTouTiao *xinWen=[[XinWenTouTiao alloc]init];
//    app.window.rootViewController=xinWen;
    a=10;

    
    UIButton *btn1=[[UIButton alloc]initWithFrame:CGRectMake(40, 60, 100, 40)];
    btn1.tag=1;
    [btn1 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    viewTiao=[[UIView alloc]initWithFrame:CGRectMake(0, 47.5, 320, 52.5)];
    viewTiao.alpha=0.2;
    viewTiao.backgroundColor=[UIColor lightGrayColor];
    viewTiao.userInteractionEnabled=NO;//不能点击直接无视它
    [self.view addSubview:viewTiao];
    [self.view addSubview:btn1];
    UIButton *btn2=[[UIButton alloc]initWithFrame:CGRectMake(40, 125, 100, 40)];
    [btn2 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    btn2.tag=2;
    [self.view addSubview:btn2];
    UIButton *btn3=[[UIButton alloc]initWithFrame:CGRectMake(40, 190, 100, 40)];
    btn3.tag=3;
    [btn3 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn3];
    UIButton *btn4=[[UIButton alloc]initWithFrame:CGRectMake(40, 255, 100, 40)];
    btn4.tag=4;
    [btn4 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn4];
    UIButton *btn5=[[UIButton alloc]initWithFrame:CGRectMake(40, 320, 100, 40)];
    btn5.tag=5;
    [btn5 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn5];
    UIButton *btn6=[[UIButton alloc]initWithFrame:CGRectMake(40, 385, 100, 40)];
    btn6.tag=6;
    [btn6 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:btn6];
    UIButton *btn7=[[UIButton alloc]initWithFrame:CGRectMake(30, 450, 25, 15)];
    [btn7 setBackgroundImage:[UIImage imageNamed:@"back@2x.png"] forState:UIControlStateNormal];
    [btn7 addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];
    btn7.tag=7;
    [self.view addSubview:btn7];
    
//    view1=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
//    view1.backgroundColor=[UIColor redColor];
//    [self.view addSubview:view1];
    scrollView1=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
    scrollView1.contentSize=CGSizeMake(320, 480);
    [self.view addSubview:scrollView1];
    UIImageView *beiJing1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
    beiJing1.image=[UIImage imageNamed:@"commonNavBar@2x.png"];
    [scrollView1 addSubview:beiJing1];
    label1=[[UILabel alloc]init];
    label1.center=beiJing1.center;
    label1.bounds=CGRectMake(0, 0, 200, 60);
    label1.text=@"头条";
    label1.textAlignment=NSTextAlignmentCenter;
    label1.font=[UIFont systemFontOfSize:30];
    [scrollView1 addSubview:label1];
    
    UIImageView *beiJingXinWen=[[UIImageView alloc]initWithFrame:CGRectMake(0, 60, 320, 420)];
    beiJingXinWen.image=[UIImage imageNamed:@"news_1.png"];
    [scrollView1 addSubview:beiJingXinWen];
    UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
    btn.frame=CGRectMake(0, 20, 30, 30);
    [btn setBackgroundImage:[UIImage imageNamed:@"n_menu@2x.png"] forState:UIControlStateNormal];
    btn.tag=11;
    [btn addTarget:self action:@selector(click2:) forControlEvents:UIControlEventTouchUpInside];
    scrollView1.tag=21;
    [scrollView1 addSubview:btn];
    
}
-(void)click2:(UIButton*)btn
{
 
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.5];
    [UIView setAnimationRepeatCount:1];
    if (btn.tag==11)
    {
        label1.textAlignment=NSTextAlignmentLeft;
        scrollView1.frame=CGRectMake(200, 60, 320, 360);
    }
    else if (btn.tag==12)
    {
        label2.textAlignment=NSTextAlignmentLeft;
        scrollView2.frame=CGRectMake(200, 60, 320, 360);
    }
    else if (btn.tag==13)
    {
        label3.textAlignment=NSTextAlignmentLeft;
        scrollView3.frame=CGRectMake(200, 60, 320, 360);
    }
    else if (btn.tag==14)
    {
        label4.textAlignment=NSTextAlignmentLeft;
        scrollView4.frame=CGRectMake(200, 60, 320, 360);
    }
    else if (btn.tag==15)
    {
        label5.textAlignment=NSTextAlignmentLeft;
        scrollView5.frame=CGRectMake(200, 60, 320, 360);
    }
    else if (btn.tag==16)
    {
        label6.textAlignment=NSTextAlignmentLeft;
        scrollView6.frame=CGRectMake(200, 60, 320, 360);
    }
    [UIView commitAnimations];
    

}
-(void)click:(UIButton*)btn
{

    if (btn.tag==7)
    {
        [self.navigationController popViewControllerAnimated:YES];
    }
    else if (btn.tag==1)
    {
        UIScrollView *scroll=(UIScrollView*)[self.view viewWithTag:a];
        scroll.frame=CGRectMake(0,0,0,0);
         scrollView1.frame=CGRectMake(200, 60, 320, 360);
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:0.5];
        [UIView setAnimationRepeatCount:1];
        scrollView1.frame=CGRectMake(0, 0, 320, 480);
        viewTiao.frame=CGRectMake(0, 47.5, 320, 52.5);
        label1.textAlignment=NSTextAlignmentCenter;
        [UIView commitAnimations];
    }
    else if (btn.tag==2)
    {
        UIScrollView *scroll=(UIScrollView*)[self.view viewWithTag:a];
        scroll.frame=CGRectMake(0,0,0,0);
        NSLog(@"00");
        if (scrollView2==nil)
        {
            NSLog(@"00");
            scrollView2=[[UIScrollView alloc]initWithFrame:CGRectMake(200, 60, 320, 360)];
            scrollView2.contentSize=CGSizeMake(320, 480);
            scrollView2.tag=22;
            [self.view addSubview:scrollView2];
            UIImageView *beiJing1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
            beiJing1.image=[UIImage imageNamed:@"commonNavBar@2x.png"];
            [scrollView2 addSubview:beiJing1];
            label2=[[UILabel alloc]init];
            label2.center=beiJing1.center;
            label2.bounds=CGRectMake(0, 0, 200, 60);
            label2.text=@"娱乐";
            label2.textAlignment=NSTextAlignmentLeft;
            label2.font=[UIFont systemFontOfSize:30];
            [scrollView2 addSubview:label2];
            
            UIImageView *beiJingXinWen=[[UIImageView alloc]initWithFrame:CGRectMake(0, 60, 320, 420)];
            beiJingXinWen.image=[UIImage imageNamed:@"news_2.png"];
            [scrollView2 addSubview:beiJingXinWen];
            UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
            btn.frame=CGRectMake(0, 20, 30, 30);
            [btn setBackgroundImage:[UIImage imageNamed:@"n_menu@2x.png"] forState:UIControlStateNormal];
            btn.tag=12;
            [btn addTarget:self action:@selector(click2:) forControlEvents:UIControlEventTouchUpInside];
            [scrollView2 addSubview:btn];
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            viewTiao.frame=CGRectMake(0, 112.5, 320, 52.5);
            scrollView2.frame=CGRectMake(0, 0, 320, 480);
            label2.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        else
        {
            scrollView2.frame=CGRectMake(200, 60, 320, 360);
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            viewTiao.frame=CGRectMake(0, 112.5, 320, 52.5);
            scrollView2.frame=CGRectMake(0, 0, 320, 480);
            label2.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
        
        }
        a=scrollView2.tag;
    
    }
    else if (btn.tag==3)
    {
        UIScrollView *scroll=(UIScrollView*)[self.view viewWithTag:a];
        scroll.frame=CGRectMake(0,0,0,0);
        NSLog(@"00");
        if (scrollView3==nil)
        {
            NSLog(@"00");
            scrollView3=[[UIScrollView alloc]initWithFrame:CGRectMake(200, 60, 320, 360)];
            scrollView3.contentSize=CGSizeMake(320, 480);
            scrollView3.tag=23;
            [self.view addSubview:scrollView3];
            UIImageView *beiJing1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
            beiJing1.image=[UIImage imageNamed:@"commonNavBar@2x.png"];
            [scrollView3 addSubview:beiJing1];
            label3=[[UILabel alloc]init];
            label3.center=beiJing1.center;
            label3.bounds=CGRectMake(0, 0, 200, 60);
            label3.text=@"体育";
            label3.textAlignment=NSTextAlignmentLeft;
            label3.font=[UIFont systemFontOfSize:30];
            [scrollView3 addSubview:label3];
            
            UIImageView *beiJingXinWen=[[UIImageView alloc]initWithFrame:CGRectMake(0, 60, 320, 420)];
            beiJingXinWen.image=[UIImage imageNamed:@"news_3.png"];
            [scrollView3 addSubview:beiJingXinWen];
            UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
            btn.frame=CGRectMake(0, 20, 30, 30);
            [btn setBackgroundImage:[UIImage imageNamed:@"n_menu@2x.png"] forState:UIControlStateNormal];
            btn.tag=13;
            [btn addTarget:self action:@selector(click2:) forControlEvents:UIControlEventTouchUpInside];
            [scrollView3 addSubview:btn];
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            scrollView3.frame=CGRectMake(0, 0, 320, 480);
            viewTiao.frame=CGRectMake(0, 177.5, 320, 52.5);
            label3.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        else
        {
            scrollView3.frame=CGRectMake(200, 60, 320, 360);
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            scrollView3.frame=CGRectMake(0, 0, 320, 480);
            viewTiao.frame=CGRectMake(0, 177.5, 320, 52.5);
            label1.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        a=scrollView3.tag;
        
    }
    else if (btn.tag==4)
    {
        UIScrollView *scroll=(UIScrollView*)[self.view viewWithTag:a];
        scroll.frame=CGRectMake(0,0,0,0);
        NSLog(@"00");
        if (scrollView4==nil)
        {
            NSLog(@"00");
            scrollView4=[[UIScrollView alloc]initWithFrame:CGRectMake(200, 60, 320, 360)];
            scrollView4.contentSize=CGSizeMake(320, 480);
            scrollView4.tag=24;
            [self.view addSubview:scrollView4];
            UIImageView *beiJing1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
            beiJing1.image=[UIImage imageNamed:@"commonNavBar@2x.png"];
            [scrollView4 addSubview:beiJing1];
            label4=[[UILabel alloc]init];
            label4.center=beiJing1.center;
            label4.bounds=CGRectMake(0, 0, 200, 60);
            label4.text=@"科技";
            label4.textAlignment=NSTextAlignmentLeft;
            label4.font=[UIFont systemFontOfSize:30];
            [scrollView4 addSubview:label4];
            
            UIImageView *beiJingXinWen=[[UIImageView alloc]initWithFrame:CGRectMake(0, 60, 320, 420)];
            beiJingXinWen.image=[UIImage imageNamed:@"news_4.png"];
            [scrollView4 addSubview:beiJingXinWen];
            UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
            btn.frame=CGRectMake(0, 20, 30, 30);
            [btn setBackgroundImage:[UIImage imageNamed:@"n_menu@2x.png"] forState:UIControlStateNormal];
            btn.tag=14;
            [btn addTarget:self action:@selector(click2:) forControlEvents:UIControlEventTouchUpInside];
            [scrollView4 addSubview:btn];
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            scrollView4.frame=CGRectMake(0, 0, 320, 480);
            viewTiao.frame=CGRectMake(0, 242.5, 320, 52.5);
            label4.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        else
        {
            scrollView4.frame=CGRectMake(200, 60, 320, 360);
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            scrollView4.frame=CGRectMake(0, 0, 320, 480);
            viewTiao.frame=CGRectMake(0, 242.5, 320, 52.5);
            label4.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        a=scrollView4.tag;
        
    }
    else if (btn.tag==5)
    {
        UIScrollView *scroll=(UIScrollView*)[self.view viewWithTag:a];
        scroll.frame=CGRectMake(0,0,0,0);
        NSLog(@"00");
        if (scrollView5==nil)
        {
            NSLog(@"00");
            scrollView5=[[UIScrollView alloc]initWithFrame:CGRectMake(200, 60, 320, 360)];
            scrollView5.contentSize=CGSizeMake(320, 480);
            scrollView5.tag=25;
            [self.view addSubview:scrollView5];
            UIImageView *beiJing1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
            beiJing1.image=[UIImage imageNamed:@"commonNavBar@2x.png"];
            [scrollView5 addSubview:beiJing1];
            label5=[[UILabel alloc]init];
            label5.center=beiJing1.center;
            label5.bounds=CGRectMake(0, 0, 200, 60);
            label5.text=@"财经";
            label5.textAlignment=NSTextAlignmentCenter;
            label5.font=[UIFont systemFontOfSize:30];
            [scrollView5 addSubview:label5];
            
            UIImageView *beiJingXinWen=[[UIImageView alloc]initWithFrame:CGRectMake(0, 60, 320, 420)];
            beiJingXinWen.image=[UIImage imageNamed:@"news_5.png"];
            [scrollView5 addSubview:beiJingXinWen];
            UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
            btn.frame=CGRectMake(0, 20, 30, 30);
            [btn setBackgroundImage:[UIImage imageNamed:@"n_menu@2x.png"] forState:UIControlStateNormal];
            btn.tag=15;
            [btn addTarget:self action:@selector(click2:) forControlEvents:UIControlEventTouchUpInside];
            [scrollView5 addSubview:btn];
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            scrollView5.frame=CGRectMake(0, 0, 320, 480);
            viewTiao.frame=CGRectMake(0, 307.5, 320, 52.5);
            label5.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        else
        {
            scrollView5.frame=CGRectMake(200, 60, 320, 360);
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            scrollView5.frame=CGRectMake(0, 0, 320, 480);
            viewTiao.frame=CGRectMake(0, 307.5, 320, 52.5);
            label5.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        a=scrollView5.tag;
        
    }
    else if (btn.tag==6)
    {
        UIScrollView *scroll=(UIScrollView*)[self.view viewWithTag:a];
        scroll.frame=CGRectMake(0,0,0,0);
        NSLog(@"00");
        if (scrollView6==nil)
        {
            NSLog(@"00");
            scrollView6=[[UIScrollView alloc]initWithFrame:CGRectMake(200, 60, 320, 360)];
            scrollView6.contentSize=CGSizeMake(320, 480);
            scrollView6.tag=26;
            [self.view addSubview:scrollView6];
            UIImageView *beiJing1=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)];
            beiJing1.image=[UIImage imageNamed:@"commonNavBar@2x.png"];
            [scrollView6 addSubview:beiJing1];
            label6=[[UILabel alloc]init];
            label6.center=beiJing1.center;
            label6.bounds=CGRectMake(0, 0, 200, 60);
            label6.text=@"时尚";
            label6.textAlignment=NSTextAlignmentLeft;
            label6.font=[UIFont systemFontOfSize:30];
            [scrollView6 addSubview:label6];
            
            UIImageView *beiJingXinWen=[[UIImageView alloc]initWithFrame:CGRectMake(0, 60, 320, 420)];
            beiJingXinWen.image=[UIImage imageNamed:@"news_6.png"];
            [scrollView6 addSubview:beiJingXinWen];
            UIButton *btn=[UIButton buttonWithType:UIButtonTypeSystem];
            btn.frame=CGRectMake(0, 20, 30, 30);
            [btn setBackgroundImage:[UIImage imageNamed:@"n_menu@2x.png"] forState:UIControlStateNormal];
            btn.tag=16;
            [btn addTarget:self action:@selector(click2:) forControlEvents:UIControlEventTouchUpInside];
            [scrollView6 addSubview:btn];
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            scrollView6.frame=CGRectMake(0, 0, 320, 480);
            viewTiao.frame=CGRectMake(0, 372.5, 320, 52.5);
            label6.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        else
        {
            scrollView6.frame=CGRectMake(200, 60, 320, 360);
            [UIView beginAnimations:nil context:nil];
            [UIView setAnimationDuration:0.5];
            [UIView setAnimationRepeatCount:1];
            scrollView6.frame=CGRectMake(0, 0, 320, 480);
            viewTiao.frame=CGRectMake(0, 372.5, 320, 52.5);
            label6.textAlignment=NSTextAlignmentCenter;
            [UIView commitAnimations];
            
        }
        a=scrollView6.tag;
        
    }

}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end







